﻿using System;
using System.Data;
using System.Collections.Generic;
using Maticsoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// BLL_tb_MidSoft_FileForm
	/// </summary>
	public partial class BLL_tb_MidSoft_FileForm
	{
		private readonly ChinaSoft.DAL.DAL_tb_MidSoft_FileForm dal=new ChinaSoft.DAL.DAL_tb_MidSoft_FileForm();
		public BLL_tb_MidSoft_FileForm()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
			return dal.GetMaxId();
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int FileFormId)
		{
			return dal.Exists(FileFormId);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int  Add(ChinaSoft.Model.Model_tb_MidSoft_FileForm model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_tb_MidSoft_FileForm model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int FileFormId)
		{
			
			return dal.Delete(FileFormId);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string FileFormIdlist )
		{
			return dal.DeleteList(FileFormIdlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_FileForm GetModel(int FileFormId)
		{
			
			return dal.GetModel(FileFormId);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_tb_MidSoft_FileForm GetModelByCache(int FileFormId)
		{
			
			string CacheKey = "Model_tb_MidSoft_FileFormModel-" + FileFormId;
			object objModel = Maticsoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(FileFormId);
					if (objModel != null)
					{
						int ModelCache = Maticsoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						Maticsoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_tb_MidSoft_FileForm)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			return dal.GetList(Top,strWhere,filedOrder);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_FileForm> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_tb_MidSoft_FileForm> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_tb_MidSoft_FileForm> modelList = new List<ChinaSoft.Model.Model_tb_MidSoft_FileForm>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_tb_MidSoft_FileForm model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_tb_MidSoft_FileForm();
					if(dt.Rows[n]["FileFormId"]!=null && dt.Rows[n]["FileFormId"].ToString()!="")
					{
						model.FileFormId=int.Parse(dt.Rows[n]["FileFormId"].ToString());
					}
					if(dt.Rows[n]["ProjectInfoId"]!=null && dt.Rows[n]["ProjectInfoId"].ToString()!="")
					{
						model.ProjectInfoId=int.Parse(dt.Rows[n]["ProjectInfoId"].ToString());
					}
					if(dt.Rows[n]["FormName"]!=null && dt.Rows[n]["FormName"].ToString()!="")
					{
					model.FormName=dt.Rows[n]["FormName"].ToString();
					}
					if(dt.Rows[n]["FileFolder"]!=null && dt.Rows[n]["FileFolder"].ToString()!="")
					{
					model.FileFolder=dt.Rows[n]["FileFolder"].ToString();
					}
					if(dt.Rows[n]["FileSaveName"]!=null && dt.Rows[n]["FileSaveName"].ToString()!="")
					{
					model.FileSaveName=dt.Rows[n]["FileSaveName"].ToString();
					}
					if(dt.Rows[n]["FileName"]!=null && dt.Rows[n]["FileName"].ToString()!="")
					{
					model.FileName=dt.Rows[n]["FileName"].ToString();
					}
					if(dt.Rows[n]["FormType"]!=null && dt.Rows[n]["FormType"].ToString()!="")
					{
					model.FormType=dt.Rows[n]["FormType"].ToString();
					}
					if(dt.Rows[n]["CreateTime"]!=null && dt.Rows[n]["CreateTime"].ToString()!="")
					{
						model.CreateTime=DateTime.Parse(dt.Rows[n]["CreateTime"].ToString());
					}
					if(dt.Rows[n]["CreateUserId"]!=null && dt.Rows[n]["CreateUserId"].ToString()!="")
					{
						model.CreateUserId=int.Parse(dt.Rows[n]["CreateUserId"].ToString());
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

